package abacab.actor;

import java.util.Queue;

import abacab.ActorSystem;
import abacab.exec.DefaultMessageExecutor.ActorRunner;
import abacab.message.Envelope;
import abacab.ref.AbstractActorRef;

/**
 * The basic implementation for the actor's context
 */
@SuppressWarnings("rawtypes")
public class ActorContextImpl implements ActorContext {
	/** The actor reference */
	private final AbstractActorRef	actorRef;

	/** The queue */
	private final Queue<Envelope>		queue;

	/** The runner */
	private volatile ActorRunner		runner;

	/**
	 * Create the context
	 * 
	 * @param actorRef
	 *          the actor reference
	 * @param queue
	 *          the queue
	 */
	public ActorContextImpl(AbstractActorRef actorRef, Queue<Envelope> queue) {
		this.actorRef = actorRef;
		this.queue = queue;
	}

	@Override
	public ActorSystem getSystem() {
		return this.actorRef.getSystem();
	}

	@Override
	public Queue<Envelope> getQueue() {
		return this.queue;
	}

	/**
	 * @return the runner
	 */
	public ActorRunner getRunner() {
		return this.runner;
	}

	/**
	 * @param r
	 *          the runner
	 */
	public void setRunner(ActorRunner r) {
		this.runner = r;
	}
}